

function loading() {
    $('.reports-user').click(function () {
        $("#mascara").fadeIn(500);
        setTimeout(function () {
            $("#mascara").hide();
            $(".wrapper_reports").fadeIn(500);
        },
                3000);


    });
}
function ajaxValida() {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
        // funcao que trata o retorno

        if (xmlhttp.status === 200 && xmlhttp.readyState === 4) {
            var tempo = setTimeout(5000);
            document.getElementsByClassName("resources").innerHTML = xmlhttp.responseText;
        }
    };
}
// ***************  Usuarios *************************// 
function cadastrarUsuario() {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }


    xmlhttp.onreadystatechange = function () {
// funcao que trata o retorno
        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {
                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }

        }
    };
    xmlhttp.open("GET", "RegisterNewUser.do", true);
    xmlhttp.send(null);
}
function doAjaxPostRegisterUser(idForm) {
    $.ajax({
        type: "POST",
        url: "RegisterUser.do",
        data: decodeURIComponent(jQuery(".frmUser").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}
function doAjaxPostFormRegisterUser(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterNewUser.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        data: decodeURIComponent(jQuery("#FormUser").serialize()),
        success: function (response) {

            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Usu&aacute;rio n&atilde;o encontrado!</strong></p>').fadeIn('fast');
        }
    });
    return false;
}
function listaUsuario() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {

        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {

                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }
        }
    };
    xmlhttp.open("GET", "SearchAllUser.do", true);
    xmlhttp.send();
}

//verifica se email já existe
function doAjaxPostValidaEmail2(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "BuscaUser.do",
        data: decodeURIComponent(jQuery("#rmUser").serialize()),
        error: function () {
            return true;
        },
        success: function () {
            $('.user-email').addClass('has-error');
            $('.help-block').text('Email já cadastrado !');

            return false;
        }

    });

    console.log('erro');

}
function doAjaxPostBuscaUser(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "BuscaUser.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        data: decodeURIComponent(jQuery("#buscaFormUser").serialize()),
        success: function (response) {

            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Usu&aacute;rio n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }

    });

    return false;

}
function doAjaxPostBuscaUserEdit(idForm) {
    $.ajax({
        type: "POST",
        url: "BuscaEditUser.do",
        data: decodeURIComponent(jQuery("#buscaEditForm").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Usu&aacute;rio n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function searchUser() {

    $.ajax({
        type: "POST",
        url: "SearchUser.do",
        beforeSend: function () {
            $('._search').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Usu&aacute;rio n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;

}
function UsuarioEdit(email) {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
// funcao que trata o retorno
        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {

                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }

        }
    };
    xmlhttp.open("GET", "BuscaUserEdit.do", true);
    xmlhttp.send();
}
function doAjaxPostUpdateUser(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "UpDateUser.do",
        data: decodeURIComponent(jQuery("#userEditForm").serialize()),
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function () {
            $(".msg").delay(2000).html('<p class="alert alert-success"><strong>Dados Atualizados com sucesso!</strong></p>').fadeIn('slow');
            window.setTimeout(function () {
                $(location).attr('href', "Home.do");
            }, 3000);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function (response) {
            $(".msg").html('<p class="alert-message warning"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 2000);
        }
    });
    return false;
}

// ***************** Contador *****************************************************//
function doAjaxPostFormRegisterAccountant(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterNewAccountant.do",
        data: decodeURIComponent(jQuery("#FormAccountant").serialize()),
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            alert('Problema com o cadastro !');
        }
    });
    return false;
}
function doAjaxPostRegisterAccountant(idForm) {
// get the form values  
    $.ajax({
        type: "POST",
        url: "RegisterAccountant.do",
        data: decodeURIComponent(jQuery("#FormAccountant").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com Inválidos!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}
function searchAccountant() {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
// funcao que trata o retorno
        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {
                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }

        }
    };
    xmlhttp.open("GET", "SearchAccountant.do", true);
    xmlhttp.send();
}
function doPostBuscaAcccountant(idForm) {

    $.ajax({
        type: "POST",
        url: "SearchEditAccountant.do",
        data: decodeURIComponent(jQuery("#buscaFormEditAccountant").serialize()),
        success: function (response) {
            console.log(response);
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Contador n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostBuscaAcccountant(idForm) {
    $.ajax({
        type: "POST",
        url: "BuscaContador.do",
        beforeSend: function () {
            $('#btnenviar').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        data: decodeURIComponent(jQuery("#buscaFormAccountant").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Contador n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostBuscaEditAcccountant(idForm) {
// get the form values  
    $.ajax({
        type: "POST",
        url: "SearchAccountantEdit.do",
        data: decodeURIComponent(jQuery("#buscaFormEditAccountant").serialize()),
        success: function (response) {
            $('#resources').html(response);

        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Contador n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function pesquisarContador() {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
// funcao que trata o retorno
        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {
                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }

        }
    };
    xmlhttp.open("GET", "SearchUser.do", true);
    xmlhttp.send();
}
function AccountantEdit(email) {
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function () {
// funcao que trata o retorno
        if (xmlhttp.status === 200) {
            if (xmlhttp.readyState === 4) {

                document.getElementById("resources").innerHTML = xmlhttp.responseText;
            }

        }
    };
    xmlhttp.open("GET", "SearchAccountantEdit.do", true);
    xmlhttp.send();
}
function doAjaxPostUpdateAccount(idForm) {
    $.ajax({
        type: "POST",
        url: "UpDateAccountant.do",
        data: decodeURIComponent(jQuery("#searchEditAccountantForm").serialize()),
        beforeSend: function () {
            $("#loading").css({display: "block"});

        },
        success: function (response) {
            $(".msg").delay(2000).html('<p class="alert alert-success"><strong>Dados Atualizados com sucesso!</strong></p>').fadeIn('slow');
            window.setTimeout(function () {
                $(location).attr('href', "Home.do");
            }, 3000);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro ao atualizar dados!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;

}


//**********************Contas ***************************************************//
function doPostFormPlanGroupAccount() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "PlanAccount.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doPostFormSubGroupAccount() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "SubGroupAccount.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}



function doPostFormRegisterAccount() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterAccount.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}



function LoadingSubGroupAccount() {

   jQuery(document).ready(function($) {
       $(document).on("change","#listaSub",function () {
            $.getJSON('SubGroupAccount.do?key=' + $(('option:selected'), $(this)).val(), function (data) {
                var subgrupos = '<option value=-1>Selecione</option>';
                $.each(data, function (index, item) {
                    subgrupos += '<option value=' + item.id + '>' + item.descricao + '</option>';
                });
                $("#lstSubGrupoDeContas").html(subgrupos);
                
            });
        });
    });
    
}

function LoadingAccounts() {

   jQuery(document).ready(function($) {
       $(document).on("change","#lstSubGrupoDeContas",function () {
             $.getJSON('SearchAccount.do?key=' + $(('option:selected'), $(this)).val(), function (data) {
                 var contas = '<option value=-1>Selecione</option>';
               $.each(data, function (index, item) {
            	   		contas += '<option value=' + item.id + '>' + item.descricao + '</option>';
                  });                 
               
               $("#SubplanoDeContas").html(contas);
                  });
});
});
}

function LoadingDescAccounts() {

	   jQuery(document).ready(function($) {
	       $(document).on("change","#SubplanoDeContas",function () {
	             $.getJSON('SearchDescAccount.do?key=' + $(('option:selected'), $(this)).val(), function (data) {
	            	 $.each(data, function (index, item) {
	            		 $(".desc").val(item.extendida);
	            	 });
	             });
	       });
	   });  
}


//*************** Grupo de Contas ***********************************************//
function doPostFormGroupAccount() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "GroupAccount.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doPostFormRegisterGroupAccount() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterGroupAccount.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});
        },
        data: decodeURIComponent(jQuery("#frmGrupoDeContas").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados Inválidos!</strong></p>').fadeIn('fast');

        }
    });

    return false;
}
function doAjaxPostValidaGroup(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "SearchGroupAccount.do",
        data: decodeURIComponent(jQuery("#frmGrupoDeContas").serialize()),
        error: function () {
            return true;
        },
        success: function () {
            $('.GrupoDeContas').addClass('has-error');
            $('.validacao.name').text('Grupo já cadastrado!');

            return false;
        }
    });
}


//*********************Empresa **************************************************//
function doAjaxPostEnterprise() {

    $.ajax({
        type: "GET",
        url: "RegisterNewEnterprise.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});

        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostCadastroEmrpesa() {

    $.ajax({
        type: "POST",
        url: "RegisterEnterprise.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});

        },
        data: decodeURIComponent(jQuery("#formEmpresa").serialize()),
        success: success(),
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Dados Inválidos!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }

    });
    return false;
}
function doAjaxPostSearchEnterprise() {

    $.ajax({
        type: "POST",
        url: "SearchEnterprise.do",
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Empresa n&atilde;o encontrada!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
//Busca dados empresa readonly 
function doAjaxPostEnterpriseSearch() {
    $.ajax({
        type: "POST",
        url: "EnterpriseSearch.do",
        data: decodeURIComponent(jQuery("#FormEnterpriseSearch").serialize()),
        success: function (response) {
            console.log(response),
                    $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Empresa n&atilde;o encontrada!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
//busca form emrpesa
function doAjaxPostEditEnterpriseSearch() {
    $.ajax({
        type: "POST",
        url: "SearchEditEnterprise.do",
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Empresa n&atilde;o encontrada!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
//busca dados empresa alter
function doAjaxPostEditEnterprise(idForm) {
    $.ajax({
        type: "POST",
        url: "SearchEnterpriseEdit.do",
        data: decodeURIComponent(jQuery("#FormEnterpriseEditSearch").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Empresa n&atilde;o encontrada!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}

//***************** Histórico ************************///
function doAjaxPostHistorico() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "Historico.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});

        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            console.log();
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }


    });
    return false;
}
function doAjaxPostBuscaHistorico() {
    $.ajax({
        type: "POST",
        url: "BuscaHistorico.do",
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro do sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostBuscarHistorico() {
    $.ajax({
        type: "POST",
        url: "BuscarHistorico.do",
        data: decodeURIComponent(jQuery("#buscaHistoricoFrm").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Historico n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostBuscarHistoricoUpdate() {
    $.ajax({
        type: "POST",
        url: "BuscarHistoricoUpdate.do",
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Historico n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostResultadoBuscarHistoricoUpdate() {
    $.ajax({
        type: "POST",
        url: "HistoricoUpdate.do",
        data: decodeURIComponent(jQuery("#buscaHistoricoFrm").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Historico n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostBuscaHistoricoDescricao() {
    $.ajax({
        type: "POST",
        url: "BuscaHistoricoDescricao.do",
        data: decodeURIComponent(jQuery("#frmHistorico").serialize()),
        success: function (response) {
            $('#resources').html(response);
        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Historico n&atilde;o encontrado!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostUpDateHistorico() {
    $.ajax({
        type: "POST",
        url: "UpDateHistorico.do",
        data: decodeURIComponent(jQuery("#frmHistorico").serialize()),
        success: function (response) {
            $(".msg").html('<p class="alert alert-success"><strong>Dados Atualizados com Sucesso!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 4000);

        },
        error: function () {
            $(".msg").html('<p class="alert alert-danger"><strong>Erro!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostFormRegisterHistorico(idForm) {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterHistorico.do",
        data: decodeURIComponent(jQuery("#frmHistorico").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}

//*************** Lançamentos  *************************//
function doAjaxPostLancamentos() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "Lancamentos.do",
        beforeSend: function () {
            $("#loading").css({display: "block"});

        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            console.log();
            $(".msg").html('<p class="alert alert-danger"><strong>Erro no sistema!</strong></p>').fadeIn('fast'),
                    setTimeout(function () {
                        $(".msg").hide();
                    }, 1000);
        }
    });
    return false;
}
function doAjaxPostCadastraLancamentos() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "Entry.do",
        data: decodeURIComponent(jQuery("#FrmLancamento").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}
function doAjaxPostCadastraContas() {
// get the form values  

    $.ajax({
        type: "POST",
        url: "RegisterNewAccount.do",
        data: decodeURIComponent(jQuery("#frmContas").serialize()),
        success: success(),
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}

//********************Relatórios *************************//
function AllUser() {

    $.ajax({
        type: "GET",
        url: "SearchAllUser.do",
        beforeSend: function () {
            $('.reports').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        success: function (response) {
            $('#resources').html(response);
        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}
function AllAccountant() {

    $.ajax({
        type: "GET",
        url: "SearchAllAccountant.do",
        beforeSend: function () {
            $('.reports').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        success: function (response) {
            $('#resources').html(response);

        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}

function AllPlanAccount() {

    $.ajax({
        type: "GET",
        url: "SearchAllPlanAccount.do",
        beforeSend: function () {
            $('.reports').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        success: function (response) {
            $('#resources').html(response);

        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}


function AllEnterprise() {

    $.ajax({
        type: "GET",
        url: "SearchAllEnterprise.do",
        beforeSend: function () {
            $('.reports').click(function () {
                $("#loading").css({display: "block"});

            });
        },
        success: function (response) {
            $('#resources').html(response);

        },
        complete: function () {
            $('#loading').css({display: "none"});
        },
        error: function () {
            $(".msg").delay(2000).html('<p class="alert-message warning"><strong>Dados com erros!</strong></p>').fadeIn('fast');

        }
    });
    return false;
}





function success() {
    //alert('Cadastro realizado com sucesso !'),

    $(".msg").delay(2000).html('<p class="alert alert-success" role="alert"><strong>Cadastro realizado com sucesso!</strong></p>').fadeIn('slow');
    window.setTimeout(function () {
        $(location).attr('href', "Home.do");
    }, 3000);
}
function error() {
    $(".msg").delay(2000).html('<p class="alert alert-danger" role="alert><strong>Dados com erros!</strong></p>').fadeIn('fast');
}
function dataLoading() {
    $("#loading").css({display: "block"});
}
function dataUnLoading() {
    $("#loading").css({display: "none"});
}

$('#responsavel a').click(function () {
    $('#empresa').css({
        display: 'none'
    });
});
$('#empresa a').click(function () {
    $('#responsavel').css({
        display: 'none'
    });
});


